-- Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
--
-- this file licensed under the Mulan PSL v2.
-- You can use this software according to the terms and conditions of the Mulan PSL v2.
-- You may obtain a copy of Mulan PSL v2 at: http://license.coscl.org.cn/MulanPSL2
--
-- THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
-- PURPOSE.
-- See the Mulan PSL v2 for more details.
--
-- Author: auto generate
-- Create: 2025-7-19
-- Description: DO NOT EDIT; Code generated by "message.lua.mako"
local validate = require 'mc.validate'
local utils = require 'mc.utils'
local mdb = require 'mc.mdb'

local SwitchRule = {}

---@class SwitchRule.Description
---@field Description string
local TDescription = {}
TDescription.__index = TDescription
TDescription.group = {}

local function TDescription_from_obj(obj)
    return setmetatable(obj, TDescription)
end

function TDescription.new(Description)
    return TDescription_from_obj({Description = Description or [=[]=]})
end
---@param obj SwitchRule.Description
function TDescription:init_from_obj(obj)
    self.Description = obj.Description or [=[]=]
end

function TDescription:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TDescription.group)
end

TDescription.from_obj = TDescription_from_obj

TDescription.proto_property = {'Description'}

TDescription.default = {''}

TDescription.struct = {{name = 'Description', is_array = false, struct = nil}}

function TDescription:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'Description', self.Description, 'string', true, errs, need_convert)

    TDescription:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TDescription.proto_property, errs, need_convert)
    return self
end

function TDescription:unpack(_)
    return self.Description
end

SwitchRule.Description = TDescription

---@class SwitchRule.Direction
---@field Direction integer
local TDirection = {}
TDirection.__index = TDirection
TDirection.group = {}

local function TDirection_from_obj(obj)
    return setmetatable(obj, TDirection)
end

function TDirection.new(Direction)
    return TDirection_from_obj({Direction = Direction or 0})
end
---@param obj SwitchRule.Direction
function TDirection:init_from_obj(obj)
    self.Direction = obj.Direction or 0
end

function TDirection:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TDirection.group)
end

TDirection.from_obj = TDirection_from_obj

TDirection.proto_property = {'Direction'}

TDirection.default = {0}

TDirection.struct = {{name = 'Direction', is_array = false, struct = nil}}

function TDirection:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'Direction', self.Direction, 'uint8', true, errs, need_convert)

    TDirection:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TDirection.proto_property, errs, need_convert)
    return self
end

function TDirection:unpack(_)
    return self.Direction
end

SwitchRule.Direction = TDirection

---@class SwitchRule.Operator
---@field Operator integer
local TOperator = {}
TOperator.__index = TOperator
TOperator.group = {}

local function TOperator_from_obj(obj)
    return setmetatable(obj, TOperator)
end

function TOperator.new(Operator)
    return TOperator_from_obj({Operator = Operator or 5})
end
---@param obj SwitchRule.Operator
function TOperator:init_from_obj(obj)
    self.Operator = obj.Operator or 5
end

function TOperator:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TOperator.group)
end

TOperator.from_obj = TOperator_from_obj

TOperator.proto_property = {'Operator'}

TOperator.default = {0}

TOperator.struct = {{name = 'Operator', is_array = false, struct = nil}}

function TOperator:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'Operator', self.Operator, 'uint8', true, errs, need_convert)

    TOperator:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TOperator.proto_property, errs, need_convert)
    return self
end

function TOperator:unpack(_)
    return self.Operator
end

SwitchRule.Operator = TOperator

---@class SwitchRule.Enabled
---@field Enabled boolean
local TEnabled = {}
TEnabled.__index = TEnabled
TEnabled.group = {}

local function TEnabled_from_obj(obj)
    return setmetatable(obj, TEnabled)
end

function TEnabled.new(Enabled)
    return TEnabled_from_obj({Enabled = Enabled == nil and true or Enabled})
end
---@param obj SwitchRule.Enabled
function TEnabled:init_from_obj(obj)
    self.Enabled = obj.Enabled == nil and true or obj.Enabled
end

function TEnabled:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TEnabled.group)
end

TEnabled.from_obj = TEnabled_from_obj

TEnabled.proto_property = {'Enabled'}

TEnabled.default = {false}

TEnabled.struct = {{name = 'Enabled', is_array = false, struct = nil}}

function TEnabled:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'Enabled', self.Enabled, 'bool', false, errs, need_convert)

    TEnabled:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TEnabled.proto_property, errs, need_convert)
    return self
end

function TEnabled:unpack(_)
    return self.Enabled
end

SwitchRule.Enabled = TEnabled

---@class SwitchRule.Reading
---@field Reading integer
local TReading = {}
TReading.__index = TReading
TReading.group = {}

local function TReading_from_obj(obj)
    return setmetatable(obj, TReading)
end

function TReading.new(Reading)
    return TReading_from_obj({Reading = Reading or 0})
end
---@param obj SwitchRule.Reading
function TReading:init_from_obj(obj)
    self.Reading = obj.Reading or 0
end

function TReading:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TReading.group)
end

TReading.from_obj = TReading_from_obj

TReading.proto_property = {'Reading'}

TReading.default = {0}

TReading.struct = {{name = 'Reading', is_array = false, struct = nil}}

function TReading:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'Reading', self.Reading, 'uint32', false, errs, need_convert)

    TReading:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TReading.proto_property, errs, need_convert)
    return self
end

function TReading:unpack(_)
    return self.Reading
end

SwitchRule.Reading = TReading

---@class SwitchRule.Threshold
---@field Threshold integer
local TThreshold = {}
TThreshold.__index = TThreshold
TThreshold.group = {}

local function TThreshold_from_obj(obj)
    return setmetatable(obj, TThreshold)
end

function TThreshold.new(Threshold)
    return TThreshold_from_obj({Threshold = Threshold or 1})
end
---@param obj SwitchRule.Threshold
function TThreshold:init_from_obj(obj)
    self.Threshold = obj.Threshold or 1
end

function TThreshold:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TThreshold.group)
end

TThreshold.from_obj = TThreshold_from_obj

TThreshold.proto_property = {'Threshold'}

TThreshold.default = {0}

TThreshold.struct = {{name = 'Threshold', is_array = false, struct = nil}}

function TThreshold:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'Threshold', self.Threshold, 'uint32', true, errs, need_convert)

    TThreshold:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TThreshold.proto_property, errs, need_convert)
    return self
end

function TThreshold:unpack(_)
    return self.Threshold
end

SwitchRule.Threshold = TThreshold

---@class SwitchRule.RuleType
---@field RuleType integer
local TRuleType = {}
TRuleType.__index = TRuleType
TRuleType.group = {}

local function TRuleType_from_obj(obj)
    return setmetatable(obj, TRuleType)
end

function TRuleType.new(RuleType)
    return TRuleType_from_obj({RuleType = RuleType or 0})
end
---@param obj SwitchRule.RuleType
function TRuleType:init_from_obj(obj)
    self.RuleType = obj.RuleType or 0
end

function TRuleType:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TRuleType.group)
end

TRuleType.from_obj = TRuleType_from_obj

TRuleType.proto_property = {'RuleType'}

TRuleType.default = {0}

TRuleType.struct = {{name = 'RuleType', is_array = false, struct = nil}}

function TRuleType:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'RuleType', self.RuleType, 'uint8', true, errs, need_convert)

    TRuleType:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TRuleType.proto_property, errs, need_convert)
    return self
end

function TRuleType:unpack(_)
    return self.RuleType
end

SwitchRule.RuleType = TRuleType

SwitchRule.interface = mdb.register_interface('bmc.kepler.Managers.ActiveStandby.SwitchRule', {
    RuleType = {'y', {}, true, 0, false},
    Threshold = {'u', {}, true, 1, false},
    Reading = {'u', {}, false, 0, false},
    Enabled = {'b', {}, false, true, false},
    Operator = {'y', {}, true, 5, false},
    Direction = {'y', {}, true, 0, false},
    Description = {'s', {}, true, '', false}
}, {}, {})

return SwitchRule
